#ifndef _sdl_canvas_h_
#define _sdl_canvas_h_

#include "sdl_layer.h"
#include "SDL.h"
#include "sdl_my_opengl.h"
#include "sdl_engine.h"
#include "sdl_exceptions.h"
#include "sdl_singleton.h"
#include "sdl_prim.h"

#ifndef sdl_open_frame_priority
#define sdl_open_frame_priority 200
#endif
#ifndef sdl_close_frame_priority
#define sdl_close_frame_priority 10000
#endif

namespace sdl_canvas {

    class screen;

    class open_frame : public sdl_layer {
        sdl_ptr<screen> current_screen;

    public:
        open_frame(const sdl_ptr<screen> & sc);
        ~open_frame();
        void update();
    };

    /////////////////

    class close_frame : public sdl_layer {
        sdl_ptr<screen> current_screen;

    public:
        close_frame(const sdl_ptr<screen> & sc);
        ~close_frame();
        virtual void update();
    };

    /////////////////
    //

    class screen_info : public sdl_singleton<screen_info>, public sdl_prim,
    depends<sdl_debug::debug> {
        friend class screen;
        SDL_Surface * screen;
        SDL_VideoInfo * info;
        int xres, yres;
        bool fullscreen;

    public:
        screen_info();
        ~screen_info();
        const SDL_Surface * get_screen();
        const SDL_VideoInfo * get_videoinfo();
        int get_xres();
        int get_yres();
        bool get_fullscreen();
    };

    class screen : public sdl_layer {
        sdl_ptr<screen_info> info;
        sdl_ptr<open_frame> of;
        sdl_ptr<close_frame> cf;

    public:
        screen(int xr, int yr, bool f);
        ~screen();
        virtual void update();

    protected:
        void init_gl();
    };
};


#endif //_sdl_canvas_h_
